package com.whcoding.designpatterns.pattern.chainofresponsibility;

import com.whcoding.designpatterns.pattern.chainofresponsibility.handler.LoginHandler;
import com.whcoding.designpatterns.pattern.chainofresponsibility.validate.ValidateAuthHandler;
import com.whcoding.designpatterns.pattern.chainofresponsibility.validate.ValidateBusinessLogicHandler;
import com.whcoding.designpatterns.pattern.chainofresponsibility.validate.ValidateLoginHandler;
import com.whcoding.designpatterns.pattern.chainofresponsibility.validate.ValidateParamHandler;
import com.whcoding.designpatterns.pattern.chainofresponsibility.vo.UserVO;

/**
 * @program: spring-boot-learning
 * @description:
 * @author: whcoding
 * @create: 2022-09-19 14:36
 **/
public class ChainofResponsibilityTest {

	public static void main(String[] args) {

		LoginHandler.Builder builder = new LoginHandler.Builder();
		//这里就是链式编程，谁在前谁在后看的清清楚楚，明明白白
		builder.addHandler(new ValidateParamHandler())
				.addHandler(new ValidateLoginHandler())
				.addHandler(new ValidateAuthHandler())
				.addHandler(new ValidateBusinessLogicHandler());
		UserVO userVO = new UserVO();
		userVO.setUserName("jack");
		userVO.setPassword("666");
		userVO.setRoleName("管理员");
		builder.build().doHandler(userVO);

	}
}
